package com.baozou.app.activity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ZoomControls;

import com.baozou.R;
import com.baozou.app.adapter.PagerAdapterDemo;
import com.baozou.app.view.DragImageView;
import com.baozou.app.view.ViewPagerDemo;
import com.baozou.framework.base.BaseActivity;

public class ViewPagerDemoActivity extends BaseActivity {
	public static final String D = "ViewPagerDemoActivity";
	DragImageView[] ivs = new DragImageView[3];
	ViewPagerDemo viewPager;
	ZoomControls zc;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_pager_demo);
		
		zc = (ZoomControls)findViewById(R.id.demo_zoom);
		
		ivs[0] = new DragImageView(this);
		Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.bg11);
		ivs[0].setBitmap(bm);
		
		ivs[1] = new DragImageView(this);
		Bitmap bm1 = BitmapFactory.decodeResource(getResources(), R.drawable.test);
		ivs[1].setBitmap(bm1);
		
		ivs[2] = new DragImageView(this);
		Bitmap bm2 = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
		ivs[2].setBitmap(bm2);
		
		viewPager = (ViewPagerDemo)findViewById(R.id.demo_pager);
		
		PagerAdapterDemo a = new PagerAdapterDemo(ivs);
		
		viewPager.setAdapter(a);
		viewPager.setPageMargin(10);
		zc.setIsZoomOutEnabled(true);
		zc.setIsZoomOutEnabled(true);
		zc.setOnZoomInClickListener(new ZoomControls.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Log.d(D, "zoomIn");
				ivs[1].zoomIn();
			}
		});
		
		zc.setOnZoomOutClickListener(new ZoomControls.OnClickListener() {
			
			@Override
			public void onClick(View v) {	
				Log.d(D, "zoomOut");
				ivs[1].zoomOut();
			}
		});
	}

}
